<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
	<h1 id="clock"></h1>
</body>
<script type="text/javascript">
	//先获取当前时间
	setInterval(function (){
		var date=new Date();
		//console.log(date);
		//getFullYear,getMonth,getHours,getMinutes,getSeconds
		var year=date.getFullYear();
		var month=date.getMonth()+1;
		var date1=date.getDate();
		var hour=date.getHours();
		var minu=date.getMinutes();
		var sec=date.getSeconds();
		//判断：小时小于十二一直循环，等于十二归零重新循环
		var jk='上午';
		if(hour>12){
				hour=hour-12;
				jk='下午';
			}
		var weekday=0;
		switch(date.getDay()){
			case 0:
				weekday="星期日";
				break;
			case 1:
				weekday="星期一";
	 			break;
			case 2:
				weekday="星期二";
				break;
			case 3:
				weekday="星期三";
				break;
			case 4:
				weekday="星期四";
				break;
			case 5:
				weekday="星期五";
				break;
			case 6:
				weekday="星期六";
				break;
			}
		var str='现在的时间是'+year+'年'+month+'月'+date1+'日'+hour+'小时'+minu+'分'+sec+'秒'+jk+weekday;
		document.getElementById('clock').innerHTML=str;
	},1000)
</script>
</html>